import os
import sys

# 1.if语句
# if (-5 > 0):
#     print("1")
# elif (3 > 2):
#     print("2")`
# else:
#     print("end")

# 2.for循环，语法：for element in iterable:
# 循环列表
# list = ['su', 'yan', 'chao']
# for i in list:
#     print(i)

# 循环字符串
# greeting = "hello"
# for e in greeting:
#     print(e)
# for循环搭配 range循环数字，range接收2个参数，第一个参数默认为0，包头不包尾
# greeting = 10
# for e in range(greeting):
#  print(e)
# for 循环遍历字典的key
# person = {'name': 'John', 'age': 30, 'city': 'New York'}
# for key in person:
#     print("key: {}, value: {}".format(key, person[key]))
# for循环搭配 enumerate 遍历列表中的索引 和 元素
# fruits = ['apple', 'banana', 'cherry']
# for index, fruit in enumerate(fruits):
#     print(index, fruit)

# for循环搭配 zip() 函数可以将多个可迭代对象打包成一个元组的列表，然后可以一起遍历。
# names = ['Alice', 'Bob', 'Charlie']
# ages = [25, 30, 35, 40]
# for name, age in zip(names, ages):
#     print(name, age)

# 3.续行符 \
# xhf = "jack" + \
#       "love rose";


# 4.格式化字符串
print("姓名: {}, 年龄: {}".format("苏彦超", 29))
print("我叫 %s 今年 %d 岁!" % ('小明', 10))

name = "jack"
print(f"name= {name}")
print(f"1+1={1 + 1}")
print(f"{1+1=}")


# 5. \r实现百分比效果
# for i in range(101):
#     print("\r{:3}%".format(i), end='')
#     time.sleep(0.05)


# 6. 逻辑运算
# a=10
# b=20
# print(a and b)
# print(a or b)
# print(not (a and b))
# print(not a)


# 7.
def example_function(a, b, *args, c=None, **kwargs):
    print("Positional arguments:")
    print("a =", a)
    print("b =", b)
    print("args =", args)
    print("Keyword arguments:")
    print("c =", c)
    print("kwargs =", kwargs)


example_function(1, 2, 3, 4, 5, c=6, x=2, y=20)


def add(a, b, c):
    return a + b + c


# 使用 *args 解包元组
a = (1, 2, 3)
result = add(*a)
print(result)

# 使用 **kwargs 解包字典
kwargs = {"a": 1, "b": 2, "c": 3}
result = add(**kwargs)
print(result)
